package com.youdoneed.common.feign;

import com.youdoneed.base.application.ResultMessage;
import com.youdoneed.common.model.FileInfo;
import org.springframework.cloud.netflix.feign.FeignClient;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;

import java.util.List;

/**
 * 文件操作相关方法。
 *
 * @author Ewing
 * @date 2017/4/26
 */
@FeignClient(value = "common", fallback = FileFallback.class)
public interface FileFeignClient {

    @RequestMapping(value = "/getFileInfo", method = RequestMethod.POST)
    ResultMessage<FileInfo> getFileInfo(@RequestParam("fileId") String fileId);

    @RequestMapping(value = "/getFileInfos", method = RequestMethod.POST)
    ResultMessage<List<FileInfo>> getFileInfos(@RequestParam("fileIds") String[] fileIds);

    /**
     * 删除文件，并返回被删除的文件信息。
     */
    @RequestMapping(value = "/deleteFile", method = RequestMethod.POST)
    ResultMessage<FileInfo> deleteFile(@RequestParam("fileId") String fileId);

    /**
     * 根据URL删除文件，并返回被删除的文件信息。
     */
    @RequestMapping(value = "/deleteByUrl", method = RequestMethod.POST)
    ResultMessage<FileInfo> deleteByUrl(@RequestParam("url") String url);

}
